﻿@model RTW.Models.TDepartment
@{
    ViewData["Title"] = "edit";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section head{
    <link href="~/css/bootstrap.min.css?v=3.3.6" rel="stylesheet" />
    <link href="~/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="~/css/animate.min.css" rel="stylesheet" />
    <link href="~/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="~/css/plugins/iCheck/custom.css" rel="stylesheet" />
    <link href="~/css/style.min.css?v=4.1.0" rel="stylesheet" />
    <style type="text/css">
        .input-group-addon {
            width: 100px;
            padding: 6px;
        }

        .input-group {
            margin-bottom: 15px;
            text-align: center;
            width: 100%;
        }

        .text-left label {
            font-weight: normal;
            margin-right: 8px;
            margin-left: 2px;
        }

        .checkbox label, .radio label {
            padding-left: 0px;
        }
    </style>

}
<form id="form1" asp-action="edit">
    <div id="dContent">
        <div class="input-group">
            <span class="input-group-addon">上级机构</span>
            @*<asp:TextBox ID="txtParentName" runat="server" CssClass="form-control" Enabled="false"></asp:TextBox>*@
            @Html.TextBoxFor(m => m.PDM.DMName, new { @class = "form-control", disabled = "disabled" , autocomplete = "off" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">机构名称</span>
            @*<asp:TextBox ID="txtDMName" runat="server" CssClass="form-control" dataType="null" Msg="机构名称不能为空!"></asp:TextBox>*@
            @Html.TextBoxFor(m => m.DMName, new { @class = "form-control", dataType = "null", Msg = "机构名称不能为空!" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">全宗号</span>
            @*<asp:TextBox ID="txtDMCode" runat="server" CssClass="form-control" dataType="null" Msg="全宗号不能为空!"></asp:TextBox>*@
            @Html.TextBoxFor(m => m.DMCode, new { @class = "form-control", dataType = "null", Msg = "全宗号不能为空!" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">建档规则</span>
            @*<asp:DropDownList ID="ddlFlag1" runat="server" CssClass="form-control">
                    <asp:ListItem Value="1" Text="按部门"></asp:ListItem>
                    <asp:ListItem Value="2" Text="按问题"></asp:ListItem>
                </asp:DropDownList>*@
            @Html.DropDownListFor(m => m.Flag1, new SelectList(
                                                  new List<object>{
                                                       new { value = 1 , text = "按部门" },
                                                       new { value = 2 , text = "按问题" }
                                                    },
                                                  "value",
                                                  "text"
                                                ), new { @class = "form-control" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">档案水印</span>
            <asp:FileUpload ID="FileUpload1" runat="server" CssClass="form-control" Style="padding-top:4px;" />

        </div>
        <div class="input-group">
            <span class="input-group-addon">传统文书规则</span>
            @*<asp:TextBox ID="txtBak2" runat="server" CssClass="form-control" Text="[全宗号]-W[年度]-[问题]-[期限代码]-[案卷号]" dataType="null" Msg="传统文书档号规则不能为空!"></asp:TextBox>*@
            @Html.TextBoxFor(m => m.Bak2, new { @class = "form-control", value = "[全宗号]-W[年度]-[问题]-[期限代码]-[案卷号]", dataType = "null", Msg = "传统文书档号规则不能为空!" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">简化文书规则</span>
            @*<asp:TextBox ID="txtBak3" runat="server" CssClass="form-control" Text="[全宗号]-WS•[年度]-[期限代码]-[问题代码]-(件号,4)" dataType="null" Msg="简化文书档号规则不能为空!"></asp:TextBox>*@
            @Html.TextBoxFor(m => m.Bak3, new { @class = "form-control", Text = "[全宗号]-WS•[年度]-[期限代码]-[问题代码]-(件号,4)", dataType = "null", Msg = "简化文书档号规则不能为空!" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">级别</span>
            @*<asp:TextBox ID="txtDMLevel" runat="server" CssClass="form-control" Enabled="false"></asp:TextBox>*@
            @Html.TextBoxFor(m => m.DMLevel, new { @class = "form-control", Enabled = "false" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">索引</span>
            @*<asp:TextBox ID="txtRowIndex" runat="server" CssClass="form-control" dataType="null,zzs" Msg="索引格式错误，真能填写正整数!"></asp:TextBox>*@
            @Html.TextBoxFor(m => m.RowIndex, new { @class = "form-control", dataType = "null,zzs", Msg = "索引格式错误，真能填写正整数!" })
        </div>
        <div class="input-group">
            <span class="input-group-addon">备注</span>
            @*<asp:TextBox ID="txtRemarks" runat="server" CssClass="form-control" TextMode="MultiLine" Height="95"></asp:TextBox>*@
            @Html.TextBoxFor(m => m.Remarks, new { @class = "form-control", TextMode = "MultiLine", Height = "95" })
        </div>
    </div>
    <div class="zui-footer">
        @*<asp:Button ID="btnSave" runat="server" CssClass="btn btn-primary btn-sm" Text="保存" OnClientClick="return verfic('tip', '#dContent');" OnClick="btnSave_Click" />*@
        <button id="btnSave" class="btn btn-primary btn-sm" type="submit">保存</button>
        <button id="btnClose" class="btn btn-default btn-sm" type="button" onclick="closePage()">关闭</button>
    </div>
    @Html.HiddenFor(m => m.ID)
</form>
@section scripts{
    <script src="~/js/jquery.min.js?v=2.1.4"></script>
    <script src="~/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="~/lib/jquery.form/jquery.form.min.js"></script>
    <script src="~/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="~/js/My97DatePicker/WdatePicker.js"></script>
    <script src="~/js/plugins/layer/layer.min.js"></script>
    <script src="~/js/plugins/iCheck/icheck.min.js"></script>
    <script src="~/js/verification.js"></script>
    <script src="~/js/zuiCode.js"></script>
    <script type="text/javascript">
        $(function () {
            $(".i-checks").iCheck({
                checkboxClass: "icheckbox_square-green",
                radioClass: "iradio_square-green"
            });
            formSubmit();
        })

        //提交
        function formSubmit() {
            $("#form1").validate({
                rules: {
                    DMName: {
                        required: true
                    },
                    DMCode: {
                        required: true
                    },
                    Bak2: {
                        required: true
                    },
                    Bak3: { required: true },
                    RowIndex: {
                        digits: true
                    }
                },
                errorPlacement: function (error, element) {
                    //错误消息不为空，提示Msg消息或默认消息
                    if (error[0].textContent != "") {
                        if (error[0].textContent != undefined) {
                            let msg = element.attr("Msg") ? element.attr("Msg") : error.textContent;
                            showTip(msg, 2);
                        }
                    }
                },
                onkeyup: false,
                focusCleanup: true,
                success: "valid",

                submitHandler: function (form) {
                    //return verfic('tip', '#dContent');
                    //var fRankName = $("select[name='fRankId']").find("option:selected").text();
                    //var fState = $("input[name='fState']").is(':checked');
                    $(form).ajaxSubmit({
                        type: "POST",
                        cache: false,
                        //data: { fRankName: fRankName, fState: fState },
                        dataType: "json",
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            if (XMLHttpRequest.status != 200) {
                                showTip(errorThrown, 2);
                            }
                        },
                        success: function (result) {

                            var state = result.success;
                            var message = result.msg;
                            if (state) {
                                showTip(message, 1, 2);
                            } else {
                                showTip(message, 2);
                            }

                        }
                    });
                }
            });
        }
    </script>
}
